﻿<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Expires" content="0" />
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="/lib/html5shiv.js"></script>
<script type="text/javascript" src="/lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/css/style.css" />
	<link rel="stylesheet" type="text/css" href="/layui.css" />
<!--[if IE 6]>
<script type="text/javascript" src="/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>用户列表</title>
	<style type="text/css" media="screen">
		a {
			color: #2B4A78;
			text-decoration: none;
		}

		a:hover {
			color: #2B4A78;
			text-decoration: underline;
		}

		a:focus, input:focus {
			outline-style: none;
			outline-width: medium;
		}

		/* custom css style: pageNum,cPageNum */
		.pageNum {
			border: 1px solid #999;
			padding: 2px 8px;
			display: inline-block;
		}

		.cPageNum {
			font-weight: bold;
			padding: 2px 5px;
		}
		#pageNav{
			-moz-user-select: none;
			-webkit-user-select: none;
			-ms-user-select: none;
		}
		#pageNav a:hover {
			text-decoration: none;
			background: #fff4d8;
		}

	</style>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 用户管理 </nav>
<div class="page-container">
	<div class="cl pd-5 bg-1 bk-gray mt-20" style="padding: 27px 5px 5px 5px;">
		<div  style=" margin:auto; width:380px; ">
			<form class="layui-form layui-form-pane" action="/queryUserByName" style="height: 38px;">
				<div style="float: left">
					<label class="layui-form-label">用户名</label>
					<div class="layui-input-inline">
						<input type="text" name="uname" id="uname"  lay-verify="required" placeholder="请输入你要查询的用户" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item"  style="float:left;clear: none;margin-bottom:0">
					<div id="button_relative">
						<button class="layui-btn" lay-submit lay-filter="aa">查询</button>
					</div>
				</div>
			</form>
		</div>
		<div style="height: 22px; text-align: right;">共有数据：<strong th:text="${total}"></strong> 条</div>
	</div>
	<div class="mt-20">
		<div class="layui-form">
		<table class="table table-border table-bordered table-bg table-hover  table-responsive">
			<thead>
				<tr class="text-c">
					<th>ID</th>
					<th >用户名称</th>
					<th>关注渠道</th>
					<th>推荐人</th>
					<th>关注状态</th>
					<th >订阅管理</th>
					<th width="120">操作</th>
					<th width="120">VIP状态</th>
				</tr>
			</thead>
			<tbody id="user_tbody" >

				<!--<tr th:each="user:${userList}" class="text-c">-->
					<!--<td th:text="${user.uid}"></td>-->
					<!--<td th:text="${user.uname}"></td>-->
					<!--&lt;!&ndash;用户状态为1表示正常，为0表示禁用&ndash;&gt;-->
					<!--<td th:if="${user.status} eq 1" class="td-status"><span class="label label-success radius">正常</span></td>-->
					<!--<td th:if="${user.status} eq 0" class="td-status"><span  class="label label-danger radius">已禁用</span></td>-->
					<!--<td th:if="${user.status} eq 0" class="f-14 td-manage"><a  style="text-decoration:none ;color: #0000cc  " th:onclick="'javascript:start('+${user.uid}+')'" href="javascript:;" title="启用">启用</a>-->
					<!--<td th:if="${user.status} eq 1"class="f-14 td-manage"><a style="text-decoration:none ;color: #0000cc " th:onclick="'javascript:forbidden('+${user.uid}+')'" href="javascript:;" title="禁用">禁用</a>-->
				<!--</tr>-->
			</tbody>
		</table>
		<script type="text/javascript" src="/pagenav1.1.cn.js"></script>
		<script type="text/javascript" src="/jquery.js"></script>
		<script type="text/javascript" src="/layui.js"></script>
		<script th:inline="javascript" type="text/javascript">
            //$(function(){ //for jquery
            window.onload = (function(){

                $("#uname").attr("value",[[${uname}]])
                //optional set
                pageNav.pre="上一页";
                pageNav.next="下一页";


                //  p,当前页码,pn,总页面
                pageNav.fn = function(p,pn){
                    // document.getElementById("test").innerHTML ="当前页:"+p+"  ,  总页: "+pn;
                    //$("#test").text("Page:"+p+" of "+pn + " pages."); // jquery调用方式
                    //alert(p);
					layui.use('form',function () {
					    var form=layui.form;
                    $.post("/queryUserByPage1", {
                            start: (p-1)*20,
                            limit:20,
							uname:[[${uname}]]
                        },
                        function (data) {
                            var tbody=$("#user_tbody");
                            tbody.html("");
                            var trData="";

                            $.each(data, function (i, item) {
                                trData += "<tr><td style='text-align: center'>"+ item.uid +"</td><td style='text-align: center'>"+ item.uname +"</td><td style='text-align: center'>"+ item.channel +"</td>"
								if(item.user_recom!=null){
                                    trData+="<td style='text-align: center' class=\"f-14 td-manage\"><a style=\"text-decoration:none ;color: #0000cc \"onclick=' start("+item.userRecomId+")'  href=\"javascript:;\" title=\"查看推荐用户\">"+item.user_recom+"</a></td>"
								}else {
                                    trData+="<td>&nbsp;</td>"
								}
								if(item.subscribe==1){
                                    trData+="<td style='text-align: center' style='text-align: center' class=\"td-status\"><span  class=\"label label-success radius\">已关注</span></td>"+"<td style='text-align: center' class=\"f-14 td-manage\"><a style=\"text-decoration:none ;color: #0000cc\"onclick='addSubscribeByUser("+item.uid+")'  title=\"新增订阅\">新增订阅</a></td>"+"<td style='text-align: center' class=\"f-14 td-manage\"><a style=\"text-decoration:none ;color: #0000cc \"onclick=' forbidden("+item.uid+")'  href=\"javascript:;\" title=\"禁用\">禁用</a></td>"
								}
								if(item.subscribe==2){
                                    trData+="<td style='text-align: center' class=\"td-status\"><span  class=\"label label-danger radius\">取消关注</span></td>"+"<td style='text-align: center' class=\"f-14 td-manage\"><a style=\"text-decoration:none ;color: #0000cc \" onclick='addSubscribeByUser("+item.uid+")'   title=\"新增订阅\">新增订阅</a></td>"+"<td style='text-align: center' class=\"f-14 td-manage\"><a style=\"text-decoration:none ;color: #0000cc \"onclick=' start("+item.uid+")'  href=\"javascript:;\" title=\"启用\">启用</a></td>"
								}
								if(item.subscribe==0){
                                    trData+="<td style='text-align: center' class=\"td-status\"><span  class=\"label label-danger radius\">订阅状态不正常(subscribe状态值为0)</span></td>"+"<td style='text-align: center' class=\"f-14 td-manage\"><a style=\"text-decoration:none ;color: #0000cc \" onclick='addSubscribeByUser("+item.uid+")'   title=\"新增订阅\">新增订阅</a></td>"+"<td style='text-align: center' class=\"f-14 td-manage\"><a style=\"text-decoration:none ;color: #0000cc \"onclick=' start("+item.uid+")'  href=\"javascript:;\" title=\"启用\">启用</a></td>";
								}
								if(item.level==0){
                                    trData+="<td style='text-align:center'>"+
                                        "<input type=\"checkbox\" name=\"yyy\" value='"+item.uid+"' lay-skin=\"switch\" lay-text=\"ON|OFF\" lay-filter=\"filter\" >"+
                                        "</td></tr>";
								}else {
                                    trData+="<td style='text-align:center'>"+
                                        "<input type=\"checkbox\" name=\"yyy\" value='"+item.uid+"'  lay-skin=\"switch\" lay-text=\"ON|OFF\" lay-filter=\"filter\" checked>"+
                                        "</td></tr>";
								}
                            });
                            tbody.append(trData);
                            form.render();
                        });

                    });
                };

                //每页数显示条数固定10条
                pageNav.go(1, [[${totalPage}]]);
            });
		</script>
		<!--<div id="test" style="height:70px;padding:30px 10px;font-size: 300%;"></div>-->

		<div style="float: right" id="pageNav"></div>
		</div>
	</div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="/my.js"></script>
<!--<script type="text/javascript" src="/layui.js"></script>-->
<!--<script type="text/javascript" >-->
    <!--layui.use('form', function(){-->
        <!--var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功-->
        <!--form.render();-->
    <!--});-->

<!--</script>-->
<script type="text/javascript">

    function forbidden(uid) {
        layer.confirm("确认要禁用吗", { title: "禁用确认" }, function (index) {
            layer.close(index);

            $.post("/changeUserStatus", {
                    uid: uid,
                    status:0//状态为0表示禁用
                },
                function (data) {
                    var datares=eval(data)
                    layer.alert(datares.msg, {
                            title: "禁用操作",
                            btn: ['确定']
                        },
                        function (index, item) {
                            //layer.close(index);
                            location.reload();
                        });
                });
        });
    }
    layui.use(['form','layer'],function () {
        var form=layui.form;
        var layer=layui.layer;
        form.on('switch(filter)',function (data) {
			if(!data.elem.checked){
                layer.alert("暂不支持取消VIP操作", {
                        title: "VIP操作",
                        btn: ['确定']
                    },
                    function (index, item) {
                        //layer.close(index);
                        location.reload();
                    });
				return ;
			}
			$.post("/updateUserLevel",{uid:data.value,level:1},function () {
            })
        });
    })

    function start(uid) {
        layer.open({
            type: 2,
            content: 'queryRecomUser?uid='+uid,
            title:"推荐用户",
            area: ['800px', '500px'],
        });
    }
    function addSubscribeByUser(uid) {
        layer.open({
            type: 2,
            content: 'openAddSubscribe?uid='+uid,
			title:"新增订阅",
            area: ['800px', '500px'],
        });
    }

</script>
</body>
</html>